package com.hxzy.module.admin.api.fallback;

import com.github.pagehelper.PageInfo;
import com.hxzy.framework.common.resp.R;
import com.hxzy.framework.common.resp.ResultCode;
import com.hxzy.module.admin.api.AdminFeignApi;
import com.hxzy.module.admin.api.account.req.AccountListReq;
import com.hxzy.module.admin.api.account.resp.AdminAccountListResp;
import com.hxzy.module.admin.api.account.resp.LoadUserResp;
import com.hxzy.module.admin.api.role.req.*;
import com.hxzy.module.admin.api.role.resp.AdminRoleResp;
import com.hxzy.module.admin.api.role.resp.RoleAuthorityTreeResp;
import feign.hystrix.FallbackFactory;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author wy
 * @Description TODO
 * @Date 2024/1/28 15:16
 * @Version 1.0
 */
@Log4j2
@Component
public class AdminFeignApiFallbackFactory implements FallbackFactory<AdminFeignApi> {
    @Override
    public AdminFeignApi create(Throwable throwable) {
        log.error(throwable);
        return new AdminFeignApiFallbackFactoryImpl();
    }

    class AdminFeignApiFallbackFactoryImpl implements AdminFeignApi{


        @Override
        public R<LoadUserResp> adminAccountLoadUser(Long accountId) {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R<PageInfo<AdminRoleResp>> adminRoleList(AdminRoleReq req) {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R<AdminRoleResp> adminRoleDetail(Long roleId) {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R<List<RoleAuthorityTreeResp>> roleAuthorityTree(Long roleId) {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R addRole(AdminRoleAddReq req) {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R editRole(AdminRoleEditReq req) {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R changeRoleAuthority(ChangeRoleAuthorityReq req) {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R changeRoleState(ChangeRoleStateReq req) {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R delRole(Long roleId) {
            return R.failed(ResultCode.DEMOTION);
        }

        @Override
        public R<PageInfo<AdminAccountListResp>> accountList(AccountListReq req) {
            return R.failed(ResultCode.DEMOTION);
        }
    }
}
